Force usage of common gbfile api.
authoroliskoli <oliskoli@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 16 Aug 2006 00:00:54 +0000 (00:00 +0000)
committeroliskoli <oliskoli@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Wed, 16 Aug 2006 00:00:54 +0000 (00:00 +0000)
git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@2303 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/arcdist.c
gpsbabel/pcx.c
gpsbabel/polygon.c
gpsbabel/tiger.c

index c173c7ca5d144e6bf0d5a16ade9c315a6201360d..ecbc75db2ebe4625dd388eaeaea61e9354a37586 100644 (file)
@@ -60,12 +60,12 @@ arcdist_process(void)
         double lat1, lon1, lat2, lon2;
        int fileline = 0;
        char *line;
-       textfile_t *tin;
+       gbfile *file_in;
 
-       tin = textfile_open_read(arcfileopt, MYNAME );
+       file_in = gbfopen(arcfileopt, "r", MYNAME);
        
         lat1 = lon1 = lat2 = lon2 = BADVAL;
-       while ((line = textfile_read(tin))) {
+       while ((line = gbfgetstr(file_in))) {
            char *pound = NULL;
            int argsfound = 0;
            
@@ -123,7 +123,7 @@ arcdist_process(void)
            lon1 = lon2;
        }
            
-       textfile_done(tin);
+       gbfclose(file_in);
 
        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
                waypoint *wp = (waypoint *) elem;
index 2d6b5764d6994aa6d85cba17e94699ca68540672..b6c33d66d475b67efaa6c69f65b1e2d3dff8ac7e 100644 (file)
@@ -24,8 +24,7 @@
 #include "garmin_tables.h"
 #include <ctype.h>
 
-static FILE *file_in;
-static FILE *file_out;
+static gbfile *file_in, *file_out;
 static short_handle mkshort_handle;
 static short_handle mkshort_handle2;   /* for track and route names */
 static char *deficon = NULL;
@@ -48,19 +47,19 @@ arglist_t pcx_args[] = {
 static void
 rd_init(const char *fname)
 {
-       file_in = xfopen(fname, "rb", MYNAME);
+       file_in = gbfopen(fname, "rb", MYNAME);
 }
 
 static void
 rd_deinit(void)
 {
-       fclose(file_in);
+       gbfclose(file_in);
 }
 
 static void
 wr_init(const char *fname)
 {
-       file_out = xfopen(fname, "w", MYNAME);
+       file_out = gbfopen(fname, "w", MYNAME);
        mkshort_handle = mkshort_new_handle();
        mkshort_handle2 = mkshort_new_handle();
 }
@@ -68,7 +67,7 @@ wr_init(const char *fname)
 static void
 wr_deinit(void)
 {
-       fclose(file_out);
+       gbfclose(file_out);
        mkshort_del_handle(&mkshort_handle);
        mkshort_del_handle(&mkshort_handle2);
 }
@@ -91,12 +90,10 @@ data_read(void)
        route_head *route = NULL;
        int n; 
        char lathemi, lonhemi;
-       textfile_t *tin;
 
        read_as_degrees  = 0;
-       tin = textfile_init(file_in);
 
-       while ((buff = textfile_read(tin)))
+       while ((buff = gbfgetstr(file_in)))
        {
                char *ibuf = lrtrim(buff);
                char *cp;
@@ -217,7 +214,6 @@ data_read(void)
                        ;
                }
        }
-       textfile_done(tin);
 }
 
 static void
@@ -246,7 +242,7 @@ gpsutil_disp(const waypoint *wpt)
        }
 
 
-       fprintf(file_out, "W  %-6.6s %c%08.5f %c%011.5f %s %5d %-40.40s %5e  %d\n",
+       gbfprintf(file_out, "W  %-6.6s %c%08.5f %c%011.5f %s %5d %-40.40s %5e  %d\n",
                 global_opts.synthesize_shortnames ?
                         mkshort_from_wpt(mkshort_handle, wpt) : 
                        wpt->shortname,
@@ -275,10 +271,10 @@ pcx_track_hdr(const route_head *trk)
         * so provide option to supppress these.
         */
        if (!cartoexploreur) {
-               fprintf(file_out, "\n\nH  TN %s\n", name);
+               gbfprintf(file_out, "\n\nH  TN %s\n", name);
        }
        xfree(name);
-       fprintf(file_out, "H  LATITUDE    LONGITUDE    DATE      TIME     ALT  ;track\n");
+       gbfprintf(file_out, "H  LATITUDE    LONGITUDE    DATE      TIME     ALT  ;track\n");
 }
 
 static void
@@ -294,9 +290,9 @@ pcx_route_hdr(const route_head *rte)
        
        /* see pcx_track_hdr */
        if (!cartoexploreur) {
-               fprintf(file_out, "\n\nR  %s\n", name);
+               gbfprintf(file_out, "\n\nR  %s\n", name);
        }
-       fprintf(file_out, "\n"
+       gbfprintf(file_out, "\n"
 "H  IDNT   LATITUDE    LONGITUDE    DATE      TIME     ALT   DESCRIPTION                              PROXIMITY     SYMBOL ;waypts\n");
 }
 
@@ -317,7 +313,7 @@ pcx_track_disp(const waypoint *wpt)
        for (tp = tbuf; *tp; tp++) {
                *tp = toupper(*tp);
        }
-       fprintf(file_out, "T  %c%08.5f %c%011.5f %s %.f\n",
+       gbfprintf(file_out, "T  %c%08.5f %c%011.5f %s %.f\n",
                        lat < 0.0 ? 'S' : 'N',
                        fabs(lat),
                        lon < 0.0 ? 'W' : 'E',
@@ -329,7 +325,7 @@ pcx_track_disp(const waypoint *wpt)
 static void
 data_write(void)
 {
-fprintf(file_out,
+gbfprintf(file_out,
 "H  SOFTWARE NAME & VERSION\n"
 "I  PCX5 2.09\n"
 "\n"
@@ -347,7 +343,7 @@ fprintf(file_out,
 
        if (global_opts.objective == wptdata)
        {
-               fprintf(file_out,
+               gbfprintf(file_out,
 "\n"
 "H  IDNT   LATITUDE    LONGITUDE    DATE      TIME     ALT   DESCRIPTION                              PROXIMITY     SYMBOL ;waypts\n");
 
index 6fc79fcd36fda93aed689272bdc038d6c824e065..5f2abce188ad53ddf8321b08105c2bcb73305150 100644 (file)
@@ -256,12 +256,12 @@ polygon_process(void)
        int first = 1;
        int last = 0;
        char *line;
-       textfile_t *tin;
+       gbfile *file_in;
 
-       tin = textfile_open_read(polyfileopt, MYNAME );
+       file_in = gbfopen(polyfileopt, "r", MYNAME);
        
         olat = olon = lat1 = lon1 = lat2 = lon2 = BADVAL;
-       while ((line = textfile_read(tin))) {
+       while ((line = gbfgetstr(file_in))) {
            char *pound = NULL;
            int argsfound = 0;
            
@@ -327,7 +327,7 @@ polygon_process(void)
                lon1 = lon2;
            }
        }
-       textfile_done(tin);
+       gbfclose(file_in);
 
        QUEUE_FOR_EACH(&waypt_head, elem, tmp) {
                waypoint *wp = (waypoint *) elem;
index d97511e6dfd0616caf1a7ef6e74d947df88c3be9..364e548a0bee9b7806051dc271c927cc5afc9a78 100644 (file)
@@ -22,8 +22,7 @@
 #include "defs.h"
 #include "csv_util.h"
 
-static FILE *file_in;
-static FILE *file_out;
+static gbfile *file_in, *file_out;
 static short_handle mkshort_handle;
 static short_handle mkshort_whandle;
 
@@ -99,28 +98,28 @@ arglist_t tiger_args[] = {
 static void
 rd_init(const char *fname)
 {
-       file_in = xfopen(fname, "rb", MYNAME);
+       file_in = gbfopen(fname, "rb", MYNAME);
        mkshort_handle = mkshort_new_handle();
 }
 
 static void
 rd_deinit(void)
 {
-       fclose(file_in);
+       gbfclose(file_in);
        mkshort_del_handle(&mkshort_handle);
 }
 
 static void
 wr_init(const char *fname)
 {
-       file_out = xfopen(fname, "w", MYNAME);
+       file_out = gbfopen(fname, "w", MYNAME);
        thresh_days = strtod(oldthresh, NULL);
 }
 
 static void
 wr_deinit(void)
 {
-       fclose(file_out);
+       gbfclose(file_out);
 }
 
 static void
@@ -131,11 +130,8 @@ data_read(void)
        char icon[100];
        char *ibuf;
        waypoint *wpt_tmp;
-       textfile_t *tin;
-
-       tin = textfile_init(file_in);
        
-       while ((ibuf = textfile_read(tin))) {
+       while ((ibuf = gbfgetstr(file_in))) {
                if( sscanf(ibuf, "%lf,%lf:%100[^:]:%100[^\n]", 
                                &lon, &lat, icon, desc)) {
                        wpt_tmp = waypt_new();
@@ -148,7 +144,6 @@ data_read(void)
                        waypt_add(wpt_tmp);
                }
        }
-       textfile_done(tin);
 }
 
 static void
@@ -174,7 +169,7 @@ tiger_disp(const waypoint *wpt)
                if (lon < minlon) minlon = lon;
        }
 
-       fprintf(file_out, "%f,%f:%s", lon, lat, pin);
+       gbfprintf(file_out, "%f,%f:%s", lon, lat, pin);
        if (!nolabels) {
                char *temp = NULL;
                char *desc = csv_stringclean(wpt->description, ":");
@@ -183,11 +178,11 @@ tiger_disp(const waypoint *wpt)
                        temp = desc;
                        desc = mkshort(mkshort_whandle, desc);
                }
-               fprintf(file_out, ":%s", desc);
+               gbfprintf(file_out, ":%s", desc);
                if (temp != NULL) desc = temp;
                xfree(desc);
        }
-       fprintf(file_out, "\n");
+       gbfprintf(file_out, "\n");
 }
 
 #if CLICKMAP
@@ -200,7 +195,7 @@ map_plot(const waypoint *wpt)
        x+=10;
        y+=10;
 
-       fprintf(linkf, "<area shape=\"circle\" coords=\"%d,%d,7\" href=\"%s\" alt=\"%s\"\n", x, y, wpt->url, wpt->description);
+       gbfprintf(linkf, "<area shape=\"circle\" coords=\"%d,%d,7\" href=\"%s\" alt=\"%s\"\n", x, y, wpt->url, wpt->description);
 }
 #endif /* CLICKMAP */
 
@@ -240,13 +235,13 @@ data_write(void)
 
        setshort_length(mkshort_whandle, short_length);
 
-       fprintf(file_out, "#tms-marker\n");
+       gbfprintf(file_out, "#tms-marker\n");
        waypt_disp_all(tiger_disp);
 
        if (genurl) {
-               FILE *urlf;
+               gbfile *urlf;
 
-               urlf = xfopen(genurl, "w", MYNAME);
+               urlf = gbfopen(genurl, "w", MYNAME);
                latsz = fabs(maxlat - minlat); 
                lonsz = fabs(maxlon - minlon); 
 
@@ -254,21 +249,21 @@ data_write(void)
                 * Center the map along X and Y axis the midpoint of
                 * our min and max coords each way.   
                 */
-               fprintf(urlf, "lat=%f&lon=%f&ht=%f&wid=%f",
+               gbfprintf(urlf, "lat=%f&lon=%f&ht=%f&wid=%f",
                                minlat + (latsz/2.0),
                                minlon + (lonsz/2.0),
                                dscale(latsz),
                                dscale(lonsz));
 
-               fprintf(urlf, "&iwd=%s&iht=%s", xpixels, ypixels);
-               fclose(urlf);
+               gbfprintf(urlf, "&iwd=%s&iht=%s", xpixels, ypixels);
+               gbfclose(urlf);
 #if CLICKMAP
                if (clickmap) {
-                       linkf = xfopen(clickmap, "w", MY NAME);
-                       fprintf(linkf, "<map name=\"map\">\n");
+                       linkf = gbfopen(clickmap, "w", MY NAME);
+                       gbfprintf(linkf, "<map name=\"map\">\n");
                        waypt_disp_all(map_plot);
-                       fprintf(linkf, "</map>\n");
-                       fclose(linkf);
+                       gbfprintf(linkf, "</map>\n");
+                       gbfclose(linkf);
                        linkf = NULL;
                }
 #endif